<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<!--引入fn函数库-->
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ page language="java"  import="java.util.*"%>
<%@page import="com.test.Person"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>EL表达式运算符</title>
	</head>

	<body>
		<h3>el表达式进行关系运算</h3>
		<%-- ${user == null}和 ${user eq null}两种写法等价--%>
		${user == null}<br />
		${user eq null }<br />
		<h3>el表达式使用empty运算符检查对象是否为null(空)</h3>
		<%
			List<String> list=new ArrayList<String>();
				list.add("ss");
			request.setAttribute("list",list);
			
		%>
		<%--使用empty运算符检查对象是否为null(空) --%>
		<c:if test="${!empty(list)}">
			<c:forEach var="item" items="${list}">
				${item}<br />
			</c:forEach>
		</c:if>
		<br />
		<%
			List<String> emptyList=null;
		%>
		<%--使用empty运算符检查对象是否为null(空) --%>
		<c:if test="${empty(list)}">
			no data
		</c:if>
		
		<h3>EL表达式中使用二元表达式</h3>
		<%
			session.setAttribute("user",new Person("session"));
		%>
		${user==null?"sorry,you no login":user.user}
		<br />
		
		<h3>EL表达式数据回显</h3>
		<%
			Person pu=new Person();
			pu.setUser("ss");
			request.setAttribute("user",pu);
		%>
		<input type="text" name="gender" value="male" ${user.user=='male'?'checked':''}>男
	</body>

</html>